﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;//Please add references
namespace TierApplication
{
	/// <summary>
	/// 类T_PRODUCT。
	/// </summary>
	public partial class T_PRODUCT
	{
	    public DataSet GetProductList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("Select a.* ,");
            strSql.Append("(Select CodeName from c_Bandwidth where CodeID=a.bandwidth) BANDWIDTHNAME,");
            strSql.Append("(Select CodeName from c_lifetime where CodeID=a.lifetime) LIFETIMENAME,");
            strSql.Append("(Select SchoolName from T_School where SchoolID=a.Schoolid) SCHOOLNAME,");
            strSql.Append("(Select CodeName from c_Categoryid where CodeID=a.Categoryid) CATEGORYNAME");
            strSql.Append(" from T_PRODUCT a");
            strSql.Append(" where 1=1" + strWhere);
            return DbHelperOra.Query(strSql.ToString());
        }

        public void SP_T_PRODUCT_DELETE(string AC_PRODUCTID, ref Int32 ai_result, ref string ac_result)
        {
            OracleParameter[] parameters ={
                                  new OracleParameter("AC_PRODUCTID",OracleType.VarChar,10),
                                  new OracleParameter("ai_result",OracleType.Int32),
                                  new OracleParameter("ac_result",OracleType.VarChar,4000)
                                                };
            parameters[0].Value = AC_PRODUCTID;
            parameters[0].Direction = ParameterDirection.Input;
            parameters[1].Direction = ParameterDirection.Output;
            parameters[2].Direction = ParameterDirection.Output;
            try
            {
                OracleCommand cmd = DbHelperOra.RunProcedureReturnCammand("SP_T_PRODUCT_DELETE", parameters);
                ai_result = int.Parse(cmd.Parameters["ai_result"].Value.ToString());
                ac_result = cmd.Parameters["ac_result"].Value.ToString();
            }
            catch (Exception e)
            {
                ai_result = -1;
                ac_result = "删除数据失败,错误原因为：" + TierService.PageValidate.RemoveChr10And13(e.Message);
            }


        }

       
	}
}

